<?php

require_once "include.php";

if($method == "GET"){
	
	$query = "SELECT * FROM canteen";

	if($_REQUEST["id"]){
		$ids = explode(",", $_REQUEST['id']);

		$i = 0;
		foreach($ids as $id){
			if($i == 0){
				$query .= " WHERE id=$id";
			} else{
				$query .= " OR id=$id";
			}

			$i++;
		}	
	}

	$result = mysql_query($query) or die(mysql_error());  

	$return_arr = array();

	while($row = mysql_fetch_array( $result )){
		$canteen = array(
					"id" => $row["id"],
					"name" => $row["name"],
					"image" => $row["image"],
					"description" => $row["description"],
					"latitude" => $row["latitude"],
					"longitude" => $row["longitude"],
					"no_of_stalls" => $row["no_of_stalls"]
					);

		$return_arr[] = $canteen;
	}

	echo json_encode($return_arr);

}
else if($method == "POST"){
	// TODO:
}
else if($method == "DELETE"){
	// TODO:
}

?>